package com.example.common.utils.text;

import android.content.Context;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.LeadingMarginSpan;

import com.example.common.R;
import com.example.common.utils.DisplayUtils;

public class TextUtils {

    /**
     * 首行缩进
     * @param context
     * @param label
     * @param description
     * @return
     */
    private SpannableString getSpannableString(Context context, String label, String description) {
        SpannableString spannableString = new SpannableString(description);
        int marginSpanSize = (int) (label.length() * context.getResources().getDimension(R.dimen.dp_10)
                + DisplayUtils.dpToPx(9));//文字宽度+padding+间隔
        //Standard(首行缩进，其他行缩进)
        LeadingMarginSpan leadingMarginSpan = new LeadingMarginSpan.Standard(marginSpanSize, 0);
        spannableString.setSpan(leadingMarginSpan, 0, description.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
        return spannableString;
    }
}
